﻿<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="DoAnPhatTrienPhanMem.Controllers" %>
<%@ Import Namespace="DoAnPhatTrienPhanMem.Models" %>
<%@ Import Namespace="DoAnPhatTrienPhanMem.Constants" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="/Scripts/CommonFunction.js" type="text/javascript"></script>
    <script src="/Scripts/Constant.js" type="text/javascript"></script>
    <link href="/Content/MainStyle.css" rel="stylesheet" type="text/css" />
    <script runat="server">
        private void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var user = "";
                if (Session[Constants.SessionName.UserName] != null) user = Session[Constants.SessionName.UserName].ToString();
                var AccountCtrl = new AccountController();

                var ID = "";
                if (ViewData.ContainsKey("ID")) ID = ViewData["ID"].ToString();
                Ext.Net.MenuItem node;

                if (AccountCtrl.CheckRole(user, "KhenThuongKiLuat", "Index"))
                {
                    node = new Ext.Net.MenuItem();
                    node.Text = "Khen thưởng và kỉ luật";
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('KhenThuongKiLuat','Index', {IDcanbo: '" + ID + "'});";
                    MainMenu.Menu.Add(node);
                }
                if (AccountCtrl.CheckRole(user, "QuaTrinhCongTac", "Index"))
                {
                    node = new Ext.Net.MenuItem();
                    node.Text = "Quá trình công tác";
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('QuaTrinhCongTac','Index', {IDcanbo: '" + ID + "'});";
                    MainMenu.Menu.Add(node);
                }
                if (AccountCtrl.CheckRole(user, "QuaTrinhHoatDong", "Index"))
                {
                    node = new Ext.Net.MenuItem();
                    node.Text = "Quá trình hoạt động";
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('QuaTrinhHoatDong','Index', {IDcanbo: '" + ID + "'});";
                    MainMenu.Menu.Add(node);
                }
                if (AccountCtrl.CheckRole(user, "QuaTrinhHocTap", "Index"))
                {
                    node = new Ext.Net.MenuItem();
                    node.Text = "Quá trình học tập";
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('QuaTrinhHocTap','Index', {IDcanbo: '" + ID + "'});";
                    MainMenu.Menu.Add(node);
                }
                if (AccountCtrl.CheckRole(user, "CanBo", "PhanCong"))
                {
                    node = new Ext.Net.MenuItem();
                    node.Text = "Phân công cán bộ";
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('CanBo','PhanCong', {IDcanbo: '" + ID + "'});";
                    MainMenu.Menu.Add(node);
                }
                if (AccountCtrl.CheckRole(user, "CanBo", "IndexLuong"))
                {
                    node = new Ext.Net.MenuItem();
                    node.Text = "Lương";
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('CanBo','IndexLuong', {ID: '" + ID + "'});";
                    MainMenu.Menu.Add(node);
                }
                if (AccountCtrl.CheckRole(user, "CanBo", "AddOrEdit"))
                {
                    node = new Ext.Net.MenuItem();
                    node.Text = "Chỉnh sửa";
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('CanBo','AddOrEdit', {ID: '" + ID + "'});";
                    MainMenu.Menu.Add(node);
                }
                if (AccountCtrl.CheckRole(user, "CanBo", "Delete"))
                {
                    node = new Ext.Net.MenuItem();
                    node.Text = "Xóa";
                    node.DirectEvents.Click.Url = "/CanBo/Delete";
                    node.DirectEvents.Click.Method = HttpMethod.POST;
                    node.DirectEvents.Click.CleanRequest = true;
                    node.DirectEvents.Click.Success = "CommonFunction.loadPage('CanBo','Index','');";
                    node.DirectEvents.Click.Failure = "";
                    node.DirectEvents.Click.Confirmation.ConfirmRequest = true;
                    node.DirectEvents.Click.Confirmation.Message = "Chắc chắn xóa cán bộ: " + ViewData["HoTen"].ToString() + " ?";
                    node.DirectEvents.Click.Confirmation.Title = "Xác nhận";
                    var param = new Ext.Net.Parameter("ID", ID);
                    node.DirectEvents.Click.ExtraParams.Add(param);
                    MainMenu.Menu.Add(node);
                }


                if (!String.IsNullOrEmpty(user))
                {
                    frmLogin.Hidden = true;
                    btnLogin.Hidden = true;
                    UserID.Text = user;
                    //UserID.NavigateUrl = "#";
                    UserID.Hidden = false;
                    afterLogin.Hidden = false;
                    var MaCB = AccountCtrl.GetByUserName(user).MaCB;
                    if (MaCB != null)
                    {
                        var CanBoCtrl = new CanBoController();
                        var IDcb = CanBoCtrl.GetSoYeuCanBoByMaCB(MaCB.ToString()).ID;
                        UserID.Listeners.Click.Handler = "CommonFunction.loadPage('CanBo','Details',{ID: '" + IDcb + "'});";
                    }
                }
            }
        }
    </script>
    <script type="text/javascript">
        function convertViTri(value) {
            if (value == "TRUONG") return "Trưởng";
            else if (value == "PHO") return "Phó";
            else if (value == "NHANVIEN") return "Nhân viên";
            else return "";
        }
        function convertKhenThuong(value) {
            if (value == "KHENTHUONG") return "Khen thưởng";
            else if (value == "KILUAT") return "Kỉ luật";
            else return "";
        }
        function loadDetails(store, records) {
            if (records.length > 0) {
                var MaCB = records[0].data.MaCB;
                window.storeKhenThuongKiLuat.reload({ params: { MaCB: MaCB} });
                window.storeQuaTrinhHoatDong.reload({ params: { MaCB: MaCB} });
                window.storeQuaTrinhCongTac.reload({ params: { MaCB: MaCB} });
                window.storeQuaTrinhHocTap.reload({ params: { MaCB: MaCB} });
            }
            else {
            }
        }
    </script>
    <style type="text/css">
        .details
        {
            width: auto;
            height: auto;
            padding-left: 10px;
        }
        .details .daumuc
        {
            background-color: #C7C7C7;
        }
    </style>
</head>
<body id="bd" class="fs3">
    <ext:ResourceManager runat="server" Locale="vi-VN" CleanResourceUrl="false" />
    <ext:Hidden runat="server" ID="txtID" Text='<%# ViewData["ID"] %>' AutoDataBind="true" />
    <ext:Store ID="storeData" runat="server">
        <Proxy>
            <ext:HttpProxy Url="/CanBo/GetDetailsByID" />
        </Proxy>
        <Reader>
            <ext:JsonReader Root="data">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="MaCB" />
                    <ext:RecordField Name="HoTen" />
                    <ext:RecordField Name="NgaySinh">
                        <Convert Fn="CommonFunction.renderDate" />
                    </ext:RecordField>
                    <ext:RecordField Name="NoiSinh" />
                    <ext:RecordField Name="GioiTinh">
                        <Convert Fn="CommonFunction.renderGioitinh" />
                    </ext:RecordField>
                    <ext:RecordField Name="DiaChi" />
                    <ext:RecordField Name="QueQuan" />
                    <ext:RecordField Name="SoDienThoai" />
                    <ext:RecordField Name="DanToc" />
                    <ext:RecordField Name="TocGiao" />
                    <ext:RecordField Name="NgayVaoDanh">
                        <Convert Fn="CommonFunction.renderDate" />
                    </ext:RecordField>
                    <ext:RecordField Name="CMND" />
                    <ext:RecordField Name="SoHieuCongChuc" />
                    <ext:RecordField Name="HocHam" />
                    <ext:RecordField Name="HocVi" />
                    <ext:RecordField Name="TenDonVi" />
                    <ext:RecordField Name="ViTri">
                        <Convert Fn="convertViTri" />
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="ID" Value="#{txtID}.getValue()" Mode="Raw" />
        </BaseParams>
        <Listeners>
            <Load Fn="loadDetails" />
        </Listeners>
    </ext:Store>
    <ext:Store runat="server" ID="storeKhenThuongKiLuat">
        <Proxy>
            <ext:HttpProxy Url="/KhenThuongKiLuat/GetLastByMaCB" />
        </Proxy>
        <Reader>
            <ext:JsonReader Root="data">
                <Fields>
                    <ext:RecordField Name="MaCB" />
                    <ext:RecordField Name="KhenThuong">
                        <Convert Fn="convertKhenThuong" />
                    </ext:RecordField>
                    <ext:RecordField Name="Ngay">
                        <Convert Fn="CommonFunction.renderDate" />
                    </ext:RecordField>
                    <ext:RecordField Name="NoiDung" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store runat="server" ID="storeQuaTrinhHoatDong">
        <Proxy>
            <ext:HttpProxy Url="/QuaTrinhHoatDong/GetLastByMaCB" />
        </Proxy>
        <Reader>
            <ext:JsonReader Root="data">
                <Fields>
                    <ext:RecordField Name="MaCB" />
                    <ext:RecordField Name="KhenThuong" />
                    <ext:RecordField Name="TuNgay">
                        <Convert Fn="CommonFunction.renderDate" />
                    </ext:RecordField>
                    <ext:RecordField Name="DenNgay">
                        <Convert Fn="CommonFunction.renderDate" />
                    </ext:RecordField>
                    <ext:RecordField Name="NoiDung" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store runat="server" ID="storeQuaTrinhCongTac">
        <Proxy>
            <ext:HttpProxy Url="/QuaTrinhCongTac/GetLastByMaCB" />
        </Proxy>
        <Reader>
            <ext:JsonReader Root="data">
                <Fields>
                    <ext:RecordField Name="MaCB" />
                    <ext:RecordField Name="KhenThuong" />
                    <ext:RecordField Name="TuNgay">
                        <Convert Fn="CommonFunction.renderDate" />
                    </ext:RecordField>
                    <ext:RecordField Name="DenNgay">
                        <Convert Fn="CommonFunction.renderDate" />
                    </ext:RecordField>
                    <ext:RecordField Name="NoiCongTac" />
                    <ext:RecordField Name="ChucVu" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store runat="server" ID="storeQuaTrinhHocTap">
        <Proxy>
            <ext:HttpProxy Url="/QuaTrinhHocTap/GetLastByMaCB" />
        </Proxy>
        <Reader>
            <ext:JsonReader Root="data">
                <Fields>
                    <ext:RecordField Name="MaCB" />
                    <ext:RecordField Name="ChuyenNganh" />
                    <ext:RecordField Name="TuNgay">
                        <Convert Fn="CommonFunction.renderDate" />
                    </ext:RecordField>
                    <ext:RecordField Name="DenNgay">
                        <Convert Fn="CommonFunction.renderDate" />
                    </ext:RecordField>
                    <ext:RecordField Name="NoiHocTap" />
                    <ext:RecordField Name="KetQua" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <div id="ja-wrapper">
        <div id="ja-container" class="wrap clearfix">
            <div class="main">
                <div class="inner clearfix">
                    <div id="ja-mainbody">
                        <ext:DataView ID="DataView1" runat="server" StoreID="storeData" ItemSelector="rowtpl">
                            <Template ID="Template1" runat="server">
                                <Html>
                                    <tpl for=".">
                                        <div class="details">
                                            <div><a href="#" onclick="CommonFunction.loadPage('CanBo','Details',{ID: '{ID}'});"><b>{HoTen}</b></a></div>
                                            <div class="daumuc"><b>Thông tin cá nhân</b></div>
                                            <div><b>Giới tính:</b>{GioiTinh}</div>
                                            <div><b>Ngày sinh:</b>{NgaySinh}</div>
                                            <div><b>Nơi sinh:</b>{NoiSinh}</div>
                                            <div><b>Quê quán:</b>{QueQuan}</div>
                                            <div><b>Dân tộc:</b>{DanToc}</div>
                                            <div><b>Tôn giáo:</b>{TonGiao}</div>
                                            <div><b>Ngày vào Đảng:</b>{NgayVaoDang}</div>
                                            <div><b>CMND:</b>{CMND}</div>
                                            <div class="daumuc"><b>Liên lạc</b></div>
                                            <div><b>Địa chỉ:</b>{DiaChi}</div>
                                            <div><b>Số điện thoại:</b>{SoDienThoai}</div>
                                            <div class="daumuc"><b>Trình độ</b></div>
                                            <div><b>Học hàm:</b>{HocHam}</div>
                                            <div><b>Học vị:</b>{HocVi}</div>
                                            <div class="daumuc"><b>Nơi công tác</b></div>
                                            <div><b>Đơn vị:</b>{TenDonVi}</div>
                                            <div><b>Vị trí:</b>{ViTri}</div>
                                        </div>
                                    </tpl>
                                </Html>
                            </Template>
                        </ext:DataView>
                        <ext:DataView ID="DataView2" runat="server" StoreID="storeKhenThuongKiLuat" ItemSelector="rowtpl">
                            <Template ID="Template2" runat="server">
                                <Html>
                                    <tpl for=".">
                                        <div class="details">
                                            <div class="daumuc"><a href="#" onclick="CommonFunction.loadPage('KhenThuongKiLuat','Index', {MaCB: '{MaCB}'});"><b>Khen thưởng kỉ luật gần đây</b></a></div>
                                            <div><b>Hình thức:</b>{KhenThuong}</div>
                                            <div><b>Ngày:</b>{Ngay}</div>
                                            <div><b>Nội dung:</b>{NoiDung}</div>
                                        </div>
                                    </tpl>
                                </Html>
                            </Template>
                        </ext:DataView>
                        <ext:DataView ID="DataView3" runat="server" StoreID="storeQuaTrinhHoatDong" ItemSelector="rowtpl">
                            <Template ID="Template3" runat="server">
                                <Html>
                                    <tpl for=".">
                                        <div class="details">
                                            <div class="daumuc"><a href="#" onclick="CommonFunction.loadPage('QuaTrinhHoatDong','Index', {MaCB: '{MaCB}'});"><b>Hoạt động gần đây</b></a></div>
                                            <div><b>Từ ngày: </b>{TuNgay} - <b>đến ngày: </b> {DenNgay}</div>
                                            <div><b>Nội dung:</b>{NoiDung}</div>
                                        </div>
                                    </tpl>
                                </Html>
                            </Template>
                        </ext:DataView>
                        <ext:DataView ID="DataView4" runat="server" StoreID="storeQuaTrinhCongTac" ItemSelector="rowtpl">
                            <Template ID="Template4" runat="server">
                                <Html>
                                    <tpl for=".">
                                        <div class="details">
                                            <div class="daumuc"><a href="#" onclick="CommonFunction.loadPage('QuaTrinhCongTac','Index', {MaCB: '{MaCB}'});"><b>Công tác gần đây</b></a></div>
                                            <div><b>Từ ngày: </b>{TuNgay} - <b>đến ngày: </b> {DenNgay}</div>
                                            <div><b>Đơn vị:</b>{NoiCongTac}</div>
                                            <div><b>Chức vụ:</b>{ChucVu}</div>
                                        </div>
                                    </tpl>
                                </Html>
                            </Template>
                        </ext:DataView>
                        <ext:DataView ID="DataView5" runat="server" StoreID="storeQuaTrinhHocTap" ItemSelector="rowtpl">
                            <Template ID="Template5" runat="server">
                                <Html>
                                    <tpl for=".">
                                        <div class="details">
                                            <div class="daumuc"><a href="#" onclick="CommonFunction.loadPage('QuaTrinhHocTap','Index', {MaCB: '{MaCB}'});"><b>Học tập gần đây</b></a></div>
                                            <div><b>Từ ngày: </b>{TuNgay} - <b>đến ngày: </b> {DenNgay}</div>
                                            <div><b>Nơi học tập:</b>{NoiHocTap}</div>
                                            <div><b>Chuyên ngành:</b>{ChuyenNganh}</div>
                                            <div><b>Kết quả:</b>{KetQua}</div>
                                        </div>
                                    </tpl>
                                </Html>
                            </Template>
                        </ext:DataView>
                    </div>
                    <div id="ja-colwrap">
                        <div class="ja-innerpad">
                            <div style="padding: 10px;">
                                <ext:CompositeField runat="server" ID="afterLogin" Hidden="true" LabelWidth="20">
                                    <Items>
                                        <ext:LinkButton runat="server" ID="UserID" />
                                        <ext:LinkButton ID="LinkButton1" runat="server" Text="(Đăng xuất)" NavigateUrl="/Account/Logout" />
                                    </Items>
                                </ext:CompositeField>
                                <ext:FormPanel runat="server" ID="frmLogin" Url="/Account/Login" Border="false" BodyBorder="false"
                                    Layout="FormLayout" AutoHeight="true" AutoWidth="true" LabelWidth="70">
                                    <Items>
                                        <ext:TextField runat="server" ID="Username" FieldLabel="Tài khoản" LabelWidth="50"
                                            AllowBlank="false" />
                                    </Items>
                                </ext:FormPanel>
                            </div>
                            <div style="padding-left: 155px;">
                                <ext:Button ID="btnLogin" runat="server" Text="Đăng nhập">
                                    <Listeners>
                                        <Click Fn="CommonFunction.submitLogin" />
                                    </Listeners>
                                </ext:Button>
                            </div>
                            <div id="Mod1" class="moduletable_menu">
                                <div class="ja-box-ct">
                                    <ul class="menu">
                                        <ext:MenuPanel runat="server" ID="MainMenu" Header="false" Border="false" />
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
